﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using EXT;

namespace BanHangCshap.Class.gkhtdl63.BLL
{
    public class Phieuxuat2BLL : DAL.Phieuxuat2DAL
    {
        public string Phieuxuat2_TaomaNgay(DateTime xlPMa, string H)
        {
            string Ma = "";
            DataTable xlDT = base.Phieuxat2_Taoma(H + String.Format("{0:0#}{1:0#}{2:0#}", xlPMa.Year, xlPMa.Month, xlPMa.Day));
            if (xlDT != null)
            {
                if (xlDT.Rows.Count > 0)
                {
                    string[] x = xlDT.Rows[0]["Ma"].ToString().Split('-');
                    Ma = x[1].ToString();
                    var xxx = Convert.ToInt32(Ma);
                    xxx++;
                    return H + String.Format("{0}{1:0#}{2:0#}-{3:00#}", xlPMa.Year, xlPMa.Month, xlPMa.Day, xxx);
                }
                else
                    return H + String.Format("{0}{1:0#}{2:0#}-{3:00#}", xlPMa.Year, xlPMa.Month, xlPMa.Day, 1);
            }
            else return H + Ma;
        }
    }
}
